| Role name | Description | Related GTK widget |
|-----------|-------------|--------------------|
| `ALERT` | A message with important information | - |
-| `BUTTON` | A control that performs an action when pressed | #GtkButton, #GtkLinkButton |
+| `BUTTON` | A control that performs an action when pressed | #GtkButton, #GtkLinkButton, #GtkExpander |
| `CHECKBOX` | A control that has three possible value: `true`, `false`, or `undefined` | #GtkCheckButton |
| `COLUMNHEADER` | The header of a column in a list or grid | - |
| `COMBOBOX` | A control that can be expanded to show a list of possible values to select | #GtkComboBox |
* GtkExpander has three CSS nodes, the main node with the name expander,
* a subnode with name title and node below it with name arrow. The arrow of an
* expander that is showing its child gets the :checked pseudoclass added to it.
+ *
+ * # Accessibility
+ *
+ * GtkExpander uses the #GTK_ACCESSIBLE_ROLE_BUTTON role.
*/
#include "config.h"
G_TYPE_NONE, 0);
gtk_widget_class_set_css_name (widget_class, I_("expander-widget"));
+ gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
}
static void
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
gtk_widget_add_controller (GTK_WIDGET (expander->title_widget), GTK_EVENT_CONTROLLER (gesture));
+
+ gtk_accessible_update_state (GTK_ACCESSIBLE (expander),
+ GTK_ACCESSIBLE_STATE_EXPANDED, FALSE,
+ -1);
}
static GtkBuildableIface *parent_buildable_iface;
gtk_expander_resize_toplevel (expander);
}
+ gtk_accessible_update_state (GTK_ACCESSIBLE (expander),
+ GTK_ACCESSIBLE_STATE_EXPANDED, expanded,
+ -1);
+
g_object_notify (G_OBJECT (expander), "expanded");
}
gtk_expander_set_child (GtkExpander *expander,
GtkWidget *child)
{
+ GList *list = NULL;
+
g_return_if_fail (GTK_IS_EXPANDER (expander));
g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
}
}
+ if (expander->child)
+ list = g_list_append (list, expander->child);
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (expander),
+ GTK_ACCESSIBLE_RELATION_CONTROLS, list,
+ -1);
+ g_list_free (list);
+
g_object_notify (G_OBJECT (expander), "child");
}
--- /dev/null
+#include <gtk/gtk.h>
+
+static void
+expander_role (void)
+{
+ GtkWidget *widget = gtk_expander_new ("Hello");
+ g_object_ref_sink (widget);
+
+ gtk_test_accessible_assert_role (widget, GTK_ACCESSIBLE_ROLE_BUTTON);
+
+ g_object_unref (widget);
+}
+
+static void
+expander_state (void)
+{
+ GtkWidget *widget = gtk_expander_new ("Hello");
+ g_object_ref_sink (widget);
+
+ gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_EXPANDED, FALSE);
+
+ gtk_expander_set_expanded (GTK_EXPANDER (widget), TRUE);
+
+ gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_EXPANDED, TRUE);
+
+ g_object_unref (widget);
+}
+
+static void
+expander_relations (void)
+{
+ GtkWidget *widget = gtk_expander_new ("Hello");
+ GtkWidget *child = gtk_label_new ("Child");
+ GList *list;
+
+ g_object_ref_sink (widget);
+
+ gtk_expander_set_child (GTK_EXPANDER (widget), child);
+
+ list = g_list_append (NULL, child);
+ gtk_test_accessible_assert_relation (widget, GTK_ACCESSIBLE_RELATION_CONTROLS, list);
+ g_list_free (list);
+
+ g_object_unref (widget);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/a11y/expander/role", expander_role);
+ g_test_add_func ("/a11y/expander/state", expander_state);
+ g_test_add_func ("/a11y/expander/relations", expander_relations);
+
+ return g_test_run ();
+}
{ 'name': 'checkbutton' },
{ 'name': 'dialog' },
{ 'name': 'entry' },
+ { 'name': 'expander' },
{ 'name': 'image' },
{ 'name': 'label' },
{ 'name': 'passwordentry' },